<%--
  Created by IntelliJ IDEA.
  User: LT
  Date: 2018-10-25
  Time: 15:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link href="${pageContext.request.contextPath}/statics/hplus/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/statics/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/statics/hplus/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/hplus/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <!--校验-->
    <script src="${pageContext.request.contextPath}/statics/bootstrapvalidator/bootstrapValidator.min.js"></script>
    <script>
        function searcha() {
            //返回表格的 Options。
            var opts = $("#jicun").bootstrapTable("getOptions") ;
            var limit = opts.pageSize ;
            var offset = (opts.pageNumber-1) * limit;
            var username = $("#username").val() ;
            $.post("${pageContext.request.contextPath}/jicun/queryByNames",{'name':username,'limit':limit,'offset':offset},function (data) {
                // var mydata = eval("("+data+")") ;
                //重新绑定表格数据
                $("#jicun").bootstrapTable('load',data) ;
            })
        }

        $(function () {
            $("#huiyuans").bootstrapTable({
                url:'${pageContext.request.contextPath}/jicun/chaxhy',
                columns:[
                    {
                        field:'huiyuan_Id',
                        title:'编号',
                        align:'center'
                    },
                    {
                        field:'huiyuan_Name',
                        title:'姓名',
                        align:'center'
                    },
                    {
                        field:'huiyuanleixing_Name',
                        title:'类型',
                        align:'center'
                    },
                    {
                        field:'huiyuan_Xingbie',
                        title:'性别',
                        align:'center'
                    },
                    {
                        field:'phone',
                        title:'联系方式'
                    }
                ],
            }) ;
        }) ;


        $(function () {

            <!--校验框架-->
            $(function () {
                $('#jiaoyan').bootstrapValidator({
                    message: '',
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    fields: {
                        quchushuliang: {
                            message: '',
                            validators: {
                                notEmpty: {
                                    message: '数量有误！请重新输入！'
                                },
                                regexp: {
                                    regexp: /^[1-9]+([.]{1}[1-9]+){0,1}$/,
                                    message: '取出数量有误！'
                                }
                            }
                        },
                    },
                });
            });

            $("#jicun").bootstrapTable({
                url:'${pageContext.request.contextPath}/jicun/ji1',
                //设置每页多少条数据
                pageSize:4,
                pageList:[4,8,16],
                height:380,
                pageNumber:1,
                //启用分页，但是默认情况下，是客户端分页的
                pagination:true,
                //启用服务器端分页
                //sidePagination:'server',
                queryParams:function(params){
                    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                        limit: params.limit,  //页面大小
                        offset: params.offset, //页码
                        username:$("#username").val()
                    };
                    return temp;
                },
                columns:[
                    {
                        field:'jicun_Danhao',
                        title:'寄存单号',
                        align:'center'
                    },
                    {
                        field:'huiyuan_Id',
                        title:'会员编号',
                        align:'center'
                    },
                    {
                        field:'huiyuan_Name',
                        title:'会员名称',
                        align:'center'
                    },
                    {
                        field:'phone',
                        title:'联系方式',
                        align:'center'
                    },
                    {
                        field:'shangpinFenlei_Name',
                        title:'商品名称',
                        align:'center'
                    },
                    {
                        field:'chanpindanwei_Name',
                        title:'单位',
                        align:'center'
                    },
                    {
                        field:'jicun_Shuliang',
                        title:'寄存数量',
                        align:'center'
                    },
                    {
                        field:'weiqu_Shuliang',
                        title:'未取数量',
                        align:'center'
                    },
                    {
                        field:'jicun_Date',
                        title:'寄存时间',
                        align:'center'
                    },
                    {
                        field:'daoqi_Date',
                        title:'到期时间',
                        align:'center'
                    },
                    {
                        field:'dianpu_Name',
                        title:'所属店铺',
                        align:'center'
                    },
                    {
                        title:'操作',
                        align:'center',
                        formatter:function(value,row,index){
                            return "<button class=\"btn btn-primary\" data-toggle=\"modal\" data-target=\".bs-example-modal-sm\"" +
                            "style='background-color:transparent;border:0px;height:35px;" +
                            "font-size: 14px' onclick='javascript:up("+row.huiyuan_Id+")' title='取回商品'>" +
                            "<span style='color: blue;margin-top: 1px' class=\"glyphicon glyphicon-open\" aria-hidden=\"true\" title='取回商品'></span></button>"
                        }
            //             <button class=\"btn btn-primary\" data-toggle=\"modal\" data-target=\".bs-example-modal-sm\"" +
            // "style='background-color:transparent;border:0px;height:35px;" +
            // "font-size: 14px' onclick='javascript:up("+row.jicun_Danhao+")' title='取回商品'>" +
            // "<span style='color: blue;margin-top: 1px' class=\"glyphicon glyphicon-open\" aria-hidden=\"true\" title='取回商品'></span></button>"
                    }
                ],
            }) ;
        }) ;





        /**
         * 修改--取出商品
         */
        var huiyuan_Id=0;
        function up(id) {
            huiyuan_Id=id;
            $("#Div1").modal("show") ;
            $.post('${pageContext.request.contextPath}/jicun/queryId',{huiyuan_Id:huiyuan_Id},function(data) {
                //$("#baocuo").html(data);
                $("[name=huiyuan_Name]").val(data.huiyuan_Name);
                $("[name=shangpinFenlei_Name]").val(data.shangpinFenlei_Name);
                $("[name=weiqu_Shuliang]").val(data.weiqu_Shuliang);
                $("[name=quchushuliang]").val(data.quchushuliang);
                $("[name=dianpu_Id]").val(data.dianpu_Id);
                $("[name=beizhu]").val(data.beizhu);
                $("[name=jicun_Danhao]").val(data.jicun_Danhao);
                $("[name=shangpinFenlei_Id]").val(data.shangpinFenlei_Id);

            })
        };
        function udadd() {
            var weiqu_Shuliang = $("[name=weiqu_Shuliang]").val();
            var quchushuliang = $("[name=quchushuliang]").val();
            var zsl = weiqu_Shuliang-quchushuliang;
            $.post('${pageContext.request.contextPath}/jicun/xiugai',{huiyuan_Id:huiyuan_Id,weiqu_Shuliang:zsl},function (data) {
                if (data!=null){
                    $("#Div3").modal("hide") ;
                    alert("取出成功！")
                } else{
                    alert("取出失败！");
                }
            });

            /**
             * 修改成功后添加商品取出记录信息
             * @type {jQuery}
             */
            var quchushuliang = $("[name=quchushuliang]").val();
            var shangpinFenlei_Id = $("[name=shangpinFenlei_Id]").val();
            var jicun_Danhao = $("[name=jicun_Danhao]").val();
            var dianpu_Id = $("[name=dianpu_Id]").val();
            var beizhu = $("[name=beizhu]").val();
            $.post('${pageContext.request.contextPath}/jicun/tiajiaSP',{quchushuliang:quchushuliang,shangpinFenlei_Id:shangpinFenlei_Id,jicun_Danhao:jicun_Danhao,dianpu_Id:dianpu_Id,beizhu:beizhu},function (data) {

            })
        }

        function toadd() {
            $("#Divtiajia").modal("show");
        }

        function huiyuan() {
            $("#showtaocanxq").modal("show");
            alert("123")
            <%--$.post('${pageContext.request.contextPath}/jicun/tchaxhy',{huiyuan_Id:huiyuan_Id},function (data) {--%>
                <%--alert(data)--%>
                <%--alert("123")--%>
            <%--})--%>
        }
        function fuwu(id) {
            $("#showtaocanxq").modal("show");
        }




    </script>

</head>
<body>
<div id = "baocuo">

</div>

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">商品寄存</h3>
    </div>
    <div class="panel-body">
        <div class="row">
            <div class="col-sm-6">
                <button onclick="toadd()" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;增加</button>
            </div>
            <div class="col-sm-12">
                <form  class="form-inline pull-right">
                    <input id="username" type="text" class="form-control">
                    <button class="btn btn-primary" onclick="searcha()" type="button"><span class="glyphicon glyphicon-search"></span>&nbsp;&nbsp;搜索</button>
                </form>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <table id="jicun"></table>
            </div>
        </div>

    </div>
</div>




<%--增加项目模态框--%>
<div class="ibox-content">
    <div class="modal inmodal" id="Divtiajia" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content animated bounceInRight">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                    </button>
                    <i class="fa fa-laptop modal-icon"></i>
                    <h4 class="modal-title">添加项目</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" method="post" id="jy">
                        <div class="form-group" style="background-color: #0d8ddb;height: 60px;margin-top: -20px;">
                            <div class="form-group" style=";margin-top: 10px">
                                <label for="title" class="col-sm-2 control-label" style="color: white">会员名称:</label>
                                <div class="col-sm-4" style="margin-left: -20px">
                                    <input  type="text" name="shangpin_Name" class="form-control" id="title" placeholder="请输入会员关键字查询">
                                </div>

                                <label for="title" class="col-sm-2 control-label" style="color: white">商品售价:</label>
                                <div class="col-sm-4" style="margin-left: -20px">
                                    <input  type="text" name="shangpin_Shoujia" class="form-control" &lt;%&ndash;id="title" placeholder="请输入会员联系方式">
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="beizhu" class="col-sm-2 control-label">备注:</label>
                            <div class="col-sm-4">
                                <input  type="text" name="beizhu"  class="form-control" placeholder="请输入套餐备注">
                            </div>
                        </div>


                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="submit" class="btn btn-primary"  onclick="doadd()">保存</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>




<%--修改模态框--%>
<div class="modal fade" id="Div1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">商品取出</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" method="post" id="jiaoyan">
                    <div class="panel panel-default memberInfo" style="width: 598px;margin-left: -15px;margin-top: -15px;margin-bottom:0px;border:0px none;border-radius:0px;background-color:#5bc0de;">
                        <div class="panel-body" id="title1">
                            <label for="huiyuan_Name" style="color:white;font-size:1.2em">会员名称:</label>
                            <strong><input style="width: 55px;color: white;border: 0px; background-color: #5BC0DE" name="huiyuan_Name"></strong>

                            <label for="shangpinFenlei_Name" style="color:white;font-size:1.2em">商品名称:</label>
                            <strong><input style="width: 65px;color: white;border: 0px; background-color: #5BC0DE" name="shangpinFenlei_Name"></strong>

                            <label for="weiqu_Shuliang" style="color:white;font-size:1.2em">可用数量:</label>
                            <strong><input style="width: 30px;color: white;border: 0px;; background-color: #5BC0DE" name="weiqu_Shuliang"></strong>
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="quchushuliang" class="col-sm-2 control-label">取出数量:</label>
                        <div class="col-sm-5">
                            <input  type="text" name="quchushuliang" class="form-control" id="title" placeholder="1">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="beizhu" class="col-sm-2 control-label">备注信息:</label>
                        <div class="col-sm-9">
                            <input  type="text" name="beizhu"  class="form-control" &lt;%&ndash;id="title"&ndash;%&gt; placeholder="在此输入备注信息">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;display: none">
                        <label for="dianpu_Id" class="col-sm-2 control-label">取出数量:</label>
                        <div class="col-sm-5">
                            <input  type="text" name="dianpu_Id" class="form-control" id="title">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;display: none">
                        <label for="jicun_Danhao" class="col-sm-2 control-label">取出数量:</label>
                        <div class="col-sm-5">
                            <input  type="text" name="jicun_Danhao" class="form-control" id="title">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;display: none">
                        <label for="shangpinFenlei_Id" class="col-sm-2 control-label">取出数量:</label>
                        <div class="col-sm-5">
                            <input  type="text" name="shangpinFenlei_Id" class="form-control" id="title">
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="submit" class="btn btn-primary"  onclick="udadd()">提交</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>






</body>
</html>
